<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <!-- MOTW-DISABLED saved from url=(0014)about:internet -->
    <title>Set up and query the data source</title>
    <link rel="StyleSheet" href="css/ChartBasics.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="css/webworks.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="webworks.css" type="text/css" media="all" />
    <script type="text/javascript" language="JavaScript1.2">
      <!--
        var  WebWorksRootPath = "";
      // -->
    </script>
  </head>
  <body>
    <div style="text-align: left;">
      <table cellspacing="0" summary="">
        <tr>
          <td>
            <a href="ch-ChartsTutorialIntro.html"><img src="images/prev.gif" alt="Previous" border="0" /></a>
          </td>
          <td>
            <a href="ch-TutT2AddTheChartToTheReport.html"><img src="images/next.gif" alt="Next" border="0" /></a>
          </td>
        </tr>
      </table>
    </div>
    <hr align="left" />
    <blockquote>
      <h3 class="N_TutorialTask-first">Task 1:&nbsp;&nbsp;<a name="297231">Set up and query the data source</a></h3>
      <p class="b_Body"><a name="297235">Before you start to design a chart, you must create a report design file for the chart, then set up the data source and data set that the chart uses. These tasks are discussed in detail in earlier sections of this book and in a tutorial in which you build a sample report. This tutorial builds on that knowledge. This task shows how to select the data to build a sample pie chart.</a></p>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">1&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="376146">To create a new report, choose File</a><span class="Dingbat">&rarr;</span>New<span class="Dingbat">&rarr;</span>Report.</div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">2&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="376149">Name the new report design Chart.rptdesign. Choose Finish. </a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">3&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="225655">Build a data source using the sample database, Classic Models. </a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">4&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="225506">Build a data set for the chart. Use the following data set name:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="cfi_CodeFirstIndent"><a name="167044">ChartData</a></div>
      <div class="N_i_Indent1"><a name="167045">Use the following SQL SELECT statement:</a></div>
      <p class="Body" style="font-family: &quot;Times New Roman&quot;; font-size: 2.0pt; margin-left: 0pt; margin-top: 0.0pt; text-indent: 0pt; vertical-align: baseline"><a name="167048">&nbsp;</a></p>
      <div class="cfi_CodeFirstIndent"><a name="167049">SELECT Products.ProductLine,</a></div>
      <div class="coi_CodeIndent"><a name="167050">sum(OrderDetails.QuantityOrdered)</a></div>
      <div class="coi_CodeIndent"><a name="167051">FROM OrderDetails,</a></div>
      <div class="coi_CodeIndent"><a name="167052">Products</a></div>
      <div class="coi_CodeIndent"><a name="167053">WHERE Products.ProductCode=OrderDetails.ProductCode</a></div>
      <div class="coi_CodeIndent"><a name="167054">GROUP BY Products.ProductLine</a></div>
      <div class="coi_CodeIndent"><a name="167055">ORDER BY Products.ProductLine</a></div>
      <div class="N_i_Indent1"><a name="167056">This SELECT statement obtains values from the ProductLine column in the Products table, groups the results by product line, and calculates the sum of the order quantities for each group. </a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">5&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="221851">Choose Finish, then Preview Results to validate the query. By creating the SELECT statement correctly, you see the data shown in </a><a href="#535186" title="Set up and query the data source">Figure&nbsp;13-1</a>. </div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i2_Image2"><a name="167067"><img class="Default" src="images/chartpreviewresults.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 13-1 Previewing the data set" /></a></p>
      <div class="fc2_FigCall2TitleFirst">
        <b class="Bold">Figure&nbsp;13-1&nbsp;&nbsp;</b><a name="535186">Previewing the data set</a></div>
      <div class="N_i_Indent1"><a name="212078">The first column lists product line names. The second column shows the total orders for each product line. BIRT uses sequential numbers to name generated columns, such as the sum column named 2 in </a><a href="#535186" title="Set up and query the data source">Figure&nbsp;13-1</a>.</div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">6&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="225811">To rename the sum column to be more descriptive, choose Output Columns. Select column 2, then choose Edit. In Edit Output Columns, use the following settings:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732283464567pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">1&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="368826">In Alias, type:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="cfi2_CodeFirstIndent2"><a name="167077">TotalOrders</a></div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732283464567pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">2&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="368847">In Display Name, type:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="cfi2_CodeFirstIndent2"><a name="368865">TOTALORDERS</a></div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732283464567pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">3&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="368873">Choose OK.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732283464567pt; white-space: nowrap">
                <span class="zAuto_0023Format">7&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="368866">To close Edit Data Set, choose OK.</a></div>
            </td>
          </tr>
        </table>
      </div>
    </blockquote>
    <hr align="left" />
    <table align="right" summary="">
      <tr>
        <td class="WebWorks_Company_Name_Bottom">
          <a href="notices.html">(c) Copyright Actuate Corporation 2013</a>
        </td>
      </tr>
    </table>
  </body>
</html>